package com.tanhua.model.vo;

import com.tanhua.model.mongo.TestPaper;
import com.tanhua.model.mongo.TestQuestion;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;


@Data
@NoArgsConstructor
@AllArgsConstructor
public class QuestionVo {

    private String id;    //问题id
    private String paperId;//所属试卷id
    private String question;   //问题名称

    private String name;   //问卷名称

    public static QuestionVo init(TestQuestion testQuestion, TestPaper testPaper) {
        QuestionVo vo = new QuestionVo();
        //设置问题数据
        BeanUtils.copyProperties(testQuestion, vo);
        vo.setId(testQuestion.getId().toHexString());

        //设置试卷
        BeanUtils.copyProperties(testPaper, vo);

        return vo;
    }
    public static QuestionVo init(TestQuestion testQuestion) {
        QuestionVo vo = new QuestionVo();
        //设置问题数据
        BeanUtils.copyProperties(testQuestion, vo);
        vo.setId(testQuestion.getId().toHexString());


        return vo;
    }
}
